package ua.kharkov.khpi.tarasenko.bach.dao.core.user;

import java.util.ArrayList;

import ua.kharkov.khpi.tarasenko.bach.core.db.EShopDataStoreException;

/**
 * Interface for DAO that works with datasource with users.
 * 
 * @author oleksandr
 * 
 */
public interface UserDAO {

	/**
	 * Finds user by it's id.
	 * 
	 * @param id
	 *            - user's id to find.
	 * @return userDTO.
	 * @throws EShopDataStoreException
	 *             if error occurred during execution.
	 */
	public UserDTO findUserById(int id) throws EShopDataStoreException;

	/**
	 * Finds user by it's email;
	 * 
	 * @param email
	 *            - user's email to find;
	 * @return userDTO - userDTO.
	 * @throws EShopDataStoreException
	 *             if error occurred during execution.
	 */
	public UserDTO findUserByEmail(String email)
			throws EShopDataStoreException;

	/**
	 * Finds all users.
	 * 
	 * @return all users.
	 * @throws EShopDataStoreException
	 *             if error occurred during execution.
	 */
	public ArrayList<UserDTO> findAllUsers()
			throws EShopDataStoreException;

	/**
	 * Adds new user.
	 * 
	 * @param user
	 *            - user to add.
	 * @return userId - this user's id.
	 * @throws EShopDataStoreException
	 *             if error occurred during execution.
	 */
	public int addUser(UserDTO user) throws EShopDataStoreException;

	/**
	 * Updates user's info.
	 * 
	 * @param userDTO
	 *            - user's info. Id from this object will be the id of the user
	 *            to update.
	 * @throws EShopDataStoreException
	 *             if error occurred during execution.
	 */
	public int update(UserDTO user) throws EShopDataStoreException;

	/**
	 * Updates user's role.
	 * 
	 * @param userDTO
	 *            - user's info. User's id and it's new role should be specified
	 *            here.
	 * @throws EShopDataStoreException
	 *             if error occurred during execution.
	 */
	public int updateUserRole(UserDTO user)
			throws EShopDataStoreException;
}
